<!DOCTYPE html>
<html>
  <head>
    <meta name="layout" content="main" />
    <title>Selección de archivo</title>
    <script type="text/javascript" src="${resource(dir: 'js', file: 'gd.js')}"></script>
    <script type="text/javascript">
    function previewDocument(fileName) {
        var baseUrl = '<g:createLink controller="document" action="openFile" />';
        var url = baseUrl + '?fileName=' + fileName;
        var previewer = GD.DocumentPreviewer();
        previewer.previewDocument(url, fileName);
    }
    </script>
  </head>
  <body>
    <div class="container">
    <div class="main-panel">
    <div class="panel panel-default">
    <div class="panel-heading"><h2>Selección de archivo <small>Archivos pendientes (${files.size()})</small></h2></div>
    <div class="panel-body">
    
    <g:if test="${flash.success}">
    <div class="alert alert-success">${flash.message}</div> 
    </g:if>
    <g:elseif test="${flash.message}">
    <div class="alert alert-danger">${flash.message}</div> 
    </g:elseif>

    <table class="table table-hover">
        <thead>
            <tr>
              <th>Archivo</th>
              <th style="text-align: center;">Vista previa</th>
              <th style="text-align: center;">Seleccionar</th>
            </tr>
        </thead>
        <tbody>
        <g:each in="${files}" var="file">
            <tr>
                <td>${file.fileName}</td>
                <td style="text-align: center;"><button type="button" class="btn btn-default" onclick="previewDocument('${file.fileName}')"><span class="glyphicon glyphicon-eye-open"></span></button></td>

                <td style="text-align: center;"><a role="button" class="btn btn-default" href="<g:createLink action="createNew" params="[fileName: file.fileName]" />"><span class="glyphicon glyphicon-step-forward"></span></a></td>
            </tr>
        </g:each>
        </tbody>
    </table>

    </div>
    </div>
    </div>
    </div>
  </body>
</html>
